{# Copyright The IETF Trust 2015, All Rights Reserved #}
{% load origin %}
{% origin %}
{% load ietf_filters static %}
{% if not docs %}
    {% if not skip_no_matches_warning %}<div class="alert alert-info my-3">No documents match your query.</div>{% endif %}
{% endif %}
{% if meta.max %}
    <div class="alert alert-warning my-3">
        Too many documents match your query! Returning only a partial result ({{ meta.max }} matches).
    </div>
{% endif %}
{% if start_table %}
    <table class="table table-sm table-striped tablesorter">
        <thead>
            <tr>
                <th scope="col"></th>
                {% for h in meta.headers %}
                    {% if h.title != "Title" %}
                        <th scope="col" data-sort="{{ h.key }}"
                            {% if h.title|slugify == "ipr" or h.title|slugify == "ad-shepherd" %}
                              class="d-none d-sm-table-cell"
                            {% elif h.title|slugify == 'date' %}
                              data-default-sort="desc"
                            {% endif %}>
                            {% if "sort_url" in h %}
                                <a href="{{ h.sort_url }}">
                                    {{ h.title|cut:" " }}
                                    {% if h.sorted and meta.max %}
                                        {% if h.direction == "asc" %}
                                            <i class="bi bi-caret-up"></i>
                                        {% else %}
                                            <i class="bi bi-caret-down"></i>
                                        {% endif %}
                                    {% endif %}
                                </a>
                            {% else %}
                                {{ h.title|cut:" " }}
                            {% endif %}
                        </th>
                    {% endif %}
                {% endfor %}
            </tr>
        </thead>
{% endif %}
{% regroup docs by search_heading as grouped_docs %}
{% for doc_group in grouped_docs %}
    <tbody>
        <tr class="table-info">
            <td></td>
            <th scope="col" colspan="{{ meta.headers|length|add:"-1" }}">
            {{ doc_group.grouper|plural:doc_group.list }} ({{ doc_group.list|length }} {{"hit"|plural:doc_group.list }})
            </th>
        </tr>
    </tbody>
    <tbody>
        {% for doc in doc_group.list %}
            {% include "doc/search/search_result_row.html" with show_ad_and_shepherd=meta.show_ad_and_shepherd %}
        {% endfor %}
    </tbody>
{% endfor %}
{% if end_table %}</table>{% endif %}